package com.naiterui.ehp.bs.pharmacist.service;

import javax.servlet.http.HttpServletRequest;

import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bp.support.exception.ResponseVO;
import com.naiterui.ehp.bs.pharmacist.entity.Pharmacist;
import com.naiterui.ehp.bs.pharmacist.vo.login.AuthFlowParamVO;
import com.naiterui.ehp.bs.pharmacist.vo.login.AuthFlowVO;
import com.naiterui.ehp.bs.pharmacist.vo.login.LoginVO;
import com.naiterui.ehp.bs.pharmacist.vo.user.RegistVO;
import com.naiterui.ehp.bs.pharmacist.vo.user.RegisterParamVO;

/**
 * @Description TODO
 * @Author gongbaoqiang
 * @Date 2019/11/30 6:19 PM
 */
public interface ILoginService {

    /**
     * 获取实名认证流程信息
     * @param flowParamVO
     * @return
     */
    AuthFlowVO authFlow(AuthFlowParamVO flowParamVO) throws BusinessException;

    /**
     * 药师注册并验证实名认证结果
     * @param authId
     * @return
     */
    ResponseVO<RegistVO> authRegist(String authId) throws BusinessException;

    /**
     * <pre>
     *     保存注册信息
     * </pre>
     * @deprecated 药师注册流程调整，使用{@link #authRegist(String)}
     * @param paramVO
     * @return
     * @throws BusinessException
     */
    @Deprecated
    RegistVO saveLogin(RegisterParamVO paramVO) throws BusinessException;

    /**
     * 根据医生loginId和密码进行登录验证，并返回登录信息
     * ILoginService.saveLoginInfoById()
     *
     * @param loginId  登录id
     * @param loginKey 登录key
     * @param password 密码
     * @param deviceSN 设备编码
     * @param request  请求对象
     *
     * @return
     *
     * @throws BusinessException
     * @Author chenlin
     * @Date 2016年3月28日
     * @since 1.0.0
     */
    LoginVO saveLoginInfoById(Long loginId, String loginKey, String password, String version, String platform, String deviceSN, String registId,
        HttpServletRequest request) throws BusinessException;

    /**
     * 短信验证登录。如果手机已经注册，则返回登录信息。如果手机号未注册，则提示注册。
     * ILoginService.saveLoginInfoByPhone()
     *
     * @param phoneNum
     * @param deviceSN
     * @param request
     *
     * @return
     *
     * @throws BusinessException
     * @since 1.0.0
     */
    LoginVO saveLoginInfoByPhone(String phoneNum, String version, String platform, String deviceSN, HttpServletRequest request)
            throws BusinessException;

    /**
     *
     * @param loginId
     * @param loginKey
     * @param password
     * @param phoneNum
     * @param version
     * @param platform
     * @param deviceSN
     * @param request
     * @return
     */
    LoginVO saveLoginCombine(Long loginId, String loginKey, String password, String phoneNum, String version, String platform, String deviceSN, HttpServletRequest request)
        throws BusinessException;

    /**
     * 获取医师信息
     * @param id
     * @return
     */
    Pharmacist findById(Long id);

    /**
     * 根据手机号获取医师信息
     * @param phone
     * @return
     */
    Pharmacist findLoginByPhoneNum(String phone);

    /**
     * 更新登陆信息
     * @param pharmacist
     */
    void updateLogin(Pharmacist pharmacist);


    /**
     * <pre>
     *     修改密码
     * </pre>
     * @param login
     * @param pwd
     * @throws BusinessException
     */
    void savePassword(Pharmacist login, String pwd) throws BusinessException;

    void saveLogoutLog(Pharmacist login, String model, String ip, String loginAddr, String deviceSN);

    void saveLoginLog(Pharmacist login, String model, String ip, String loginAddr, String deviceSN);


    /**
     * 计算验证错误次数并判断redisKey对应的错误验证码验证次数是否在规定时间内超过规定值，如果超过验证次数，则返回true,否则返回false.
     *
     * @param cacheKey
     *
     * @return
     */
    boolean validUserOperator(String cacheKey);
}
